﻿
#region USING STATEMENTS

using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

#endregion USING STATEMENTS



namespace Gsp315_AIBehaviors
{
    class Enemy
    {

        #region DATA MEMBERS

        private Texture2D texture;
        private Vector2 position;
        private Vector2 size;
        private Vector2 scale;
        private float rotation;
        private float speed;
        private Vector2 center;
        private Random randomNumber = new Random();
        bool check = true;
        int number;

        #endregion DATA MEMBERS



        #region OBJECT CONSTRUCTION

        public Enemy(Texture2D newTexture)
        {
            texture = newTexture;
            position = new Vector2(0, 0);
            size = new Vector2(32, 32);
            //center = position + (size/2);
            scale = new Vector2(1, 1);
            rotation = randomNumber.Next(1, 360);
            speed = 2.0f;
        }// end Constructor()

        public Enemy(Texture2D newTexture, Vector2 position, Vector2 size)
        {
            texture = newTexture;
            this.position = position;
            this.size = size;
            //center = position + (size/2);
            scale = new Vector2(1, 1);
            rotation = randomNumber.Next(1, 360);
            speed = 2.0f;
        }// end Overloaded Constructor 2()

        #endregion OBJECT CONSTRUCTION



        #region PROPERTIES

        public Texture2D Texture
        {
            get{ return texture; }
            set{ texture = value; }
        }

        public Vector2 Position
        {
            get{ return position; }
            set{ position = value; }
        }

        public Vector2 Center
        {
            get { return center; }
            set { center = value; }
        }

        public Vector2 Size
        {
            get { return size; }
            set { size = value; }
        }

        public float Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        #endregion PROPERTIES



        #region PUBLIC METHODS

        public void move()
        {

          
            if (check == true)
            {
                number = randomNumber.Next(0, 2);
                check = false;
            }

            if (number == 0)
            {
                position -= new Vector2(speed, 0);
            }
            else
            {
                position += new Vector2(speed, 0);
            }

            if ((position.X) <= 0)
            {
                //position.X = 0;
                number = 1;
            }
            else if ((position.X + size.X) >= (800))// - size.X))
            {
                number = 0;
            }
            
        }

        public void getRandomRotation()
        {
            rotation += .1f;//randomNumber.Next(1, 360);
        }

        public void setRandomPosition()
        {
            int r1 = randomNumber.Next(1, 800);
            int r2 = randomNumber.Next(1, 600);

            position = new Vector2((float)r1, (float)r2);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            int xPos = (int)position.X;
            int yPos = (int)position.Y;
            center =  new Vector2((size.X / 2), ((size.Y / 2) + 4));

            spriteBatch.Draw(texture, new Vector2(xPos + center.X, yPos + center.Y), null, Color.White, rotation, center, scale, SpriteEffects.None, 0f);
        }// end Draw() 

        #endregion PUBLIC METHODS     

    }// end class
}// end namespace
